home *** CD-ROM | disk | FTP | other *** search
-
-
- /*
- * ANSIPRT.C - reads a file with ANSI carriage control characters from STDIN
- * and writes an expanded file to STDOUT. Use redirection to
- * control input and output.
- */
-
- #include <stdio.h>
- #include <string.h>
-
- char inline[1024];
-
- main()
- {
- char *workptr;
-
- fgets(inline, sizeof(inline), stdin);
-
- while(!feof(stdin))
- {
- switch(inline[0])
- {
- case '1': /* formfeed */
- fputc('\n',stdout);
- fputc('\f',stdout);
- break;
- case '0': /* double-space */
- fputc('\n',stdout);
- fputc('\n',stdout);
- break;
- case '-': /* triple-space */
- fputc('\n',stdout);
- fputc('\n',stdout);
- fputc('\n',stdout);
- break;
- case '+': /* overwrite */
- fputc('\r',stdout);
- break;
- default: /* single-space by default */
- fputc('\n',stdout);
- break;
- }
-
- workptr = strchr(inline, '\n'); /* Convert LF to CR */
- if(workptr != NULL)
- *workptr = '\r';
-
- fputs(&inline[1], stdout); /* skip first character */
-
- fgets(inline, sizeof(inline), stdin);
- }
- }
-
-